//
//  VSSystemTableViewController.m
//  VS
//
//  Created by qi tan on 2023/12/21.
//

#import "VSSystemTableViewController.h"

@interface VSSystemTableViewController ()

@property (weak, nonatomic) IBOutlet UILabel *lblTarget;
@property (weak, nonatomic) IBOutlet UILabel *lblTargetName;

// 中文或英文，APP内部切换。
@property (nonatomic, copy)NSString *fileName;






@end

@implementation VSSystemTableViewController







- (void)viewDidLoad {
    [super viewDidLoad];
    // 1.app名称国际化，InfoPlist.strings
    // 2.sb国际化，storyboard生成strings国际化支持
    // 3.lan_en.strings  lan_zh.strings 应用内国际化(不依赖系统的语言)
    // 4. Localizable.strings 代码内国际化
    NSString *title = NSLocalizedString(@"title", nil);
    self.lblTarget.text = title;
    
    NSString *switchTarget = NSLocalizedString(@"switch_target", nil);
    self.lblTargetName.text = switchTarget;
    
    NSString *titleStr = NSLocalizedString(@"system_menu", nil);
    self.navigationItem.title = titleStr;
    
    
        
}

#pragma mark - Table view data source


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    NSString *headerTitle = nil;
    if(section ==0) {
        headerTitle = NSLocalizedString(@"switch_target", nil);
    } else if(section==1) {
        headerTitle = NSLocalizedString(@"device_setting", nil);
    } else {
        headerTitle = NSLocalizedString(@"back", nil);
    }
    return headerTitle;
}



#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // section分组序号，row组内的序号，序号从0开始。
    if(indexPath.section == 0 && indexPath.row == 0) {
        [self show00_00Dialog];
    }
}



// CFBundleDisplayName
# pragma mark 弹框选择内容
- (void) show00_00Dialog {
    UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

    // 国际化-代码。
    // NSString *title = NSLocalizedString(@"qm_range_0", nil);
    // app内部国际化。
    
    for (int i=0; i<7;i++ ) {
        NSString *imgName = [NSString stringWithFormat:@"qm_range_%01d", i];
        NSString *title = NSLocalizedString(imgName, nil);
        // 选择了item
        UIAlertAction *action = [UIAlertAction actionWithTitle:title
                                                        style:UIAlertActionStyleDefault
                                                    handler:^(UIAlertAction * _Nonnull action) {
            self.lblTarget.text = action.title;
            [self selectTarget:i];
        }];
        // 添加actionSheet
        [actionSheetController addAction:action];
    }
    NSString *cancel = NSLocalizedString(@"cancel", nil);
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancel
                                                           style:UIAlertActionStyleCancel
                                                         handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"取消");
    }];
    [actionSheetController addAction:cancelAction];
    [self presentViewController:actionSheetController animated:YES completion:nil];
}

// 处理用户选择，发送http数据给设备。
- (void) selectTarget: (int)index {
    NSLog(@"select:%d" , index);
}




/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
